package com.slidemenu;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.widget.RelativeLayout;
import android.widget.ScrollView;

public class MyView extends RelativeLayout {

	public MyView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public MyView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public MyView(Context context) {
		super(context);
	}
	
	private float downX;
	private float mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
	private boolean isDrag = false;
	
	public boolean isDrag() {
		return isDrag;
	}
	
	@Override
	public boolean dispatchTouchEvent(MotionEvent ev) {
		switch (ev.getAction()) {
		case MotionEvent.ACTION_DOWN:
			downX = ev.getRawX();
			break;
		case MotionEvent.ACTION_MOVE:
			float delta = ev.getRawX() - downX;
			isDrag = Math.abs(delta) > mTouchSlop ? true : false;
			break;
		default:
			isDrag = false;
			break;
		}
		return super.dispatchTouchEvent(ev);
	}
	

	@Override
	public boolean onInterceptTouchEvent(MotionEvent ev) {
		return isDrag;
	}
	
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		return super.onTouchEvent(event);
	}
	
}
